// sysModel.js
const Base = require('../base.js');
// https://testjoylearning.bmw.com.cn:8080/sys/storeApprove/list?pageNo=1&pageSize=10
module.exports = function(sequelize, DataTypes) {
    function getAttributes(sequelize, DataTypes) {
        const attributes = {
            modelId: {
                field: "model_id",
                type: DataTypes.BIGINT(20),
                primaryKey: true,
                comment: "模型ID"
            },
            modelCode: {
                field: "model_code",
                type: DataTypes.STRING(50),
                allowNull: false,
                comment: "模型编码"
               
            },
            modelName: {
                field: "model_name",
                type: DataTypes.STRING(50),
                allowNull: false,
                comment: "模型名称"
               
            },
            modelAlName: {
                field: "model_al_name",
                type: DataTypes.STRING(50),
                allowNull: true,
                comment: "模型别名",
                
            },
            tableName: {
                field: "table_name",
                type: DataTypes.STRING(200),
                allowNull: true,
                comment: "物理表名称",
                
            },
            className: {
                field: "class_name",
                type: DataTypes.STRING(200),
                allowNull: true,
                comment: "类名称",
                
            },
            indexName: {
                field: "index_name",
                type: DataTypes.STRING(200),
                allowNull: true,
                comment: "索引名称",
            },
            systemFlag: {
                field: "system_flag",
                type: DataTypes.BIGINT(11),
                allowNull: true,
                comment: "是否系统字段",
            },
            modelState: {
                field: "model_state",
                type: DataTypes.STRING(20),
                allowNull: true,
                comment: "状态 10=新建 20=发布 30=停用",
            },
            modelType: {
                field: "model_type",
                type: DataTypes.STRING(10),
                allowNull: true,
                comment: "模型类别",
            },
            ...Base.getAttr(sequelize, DataTypes)
            
            
        };
        return attributes;
    };
    const sysModel = sequelize.define('sysModel', getAttributes(sequelize, DataTypes), {
        freezeTableName: true,
        tableName: "sys_model",
        timestamps: false
    });
    
    sysModel.getHasMany = function(){
        return ["sysModelAttrs"];
    };
    Base.extendModel(sysModel, getAttributes(sequelize, DataTypes));
    return sysModel;
};